   <!--良品条件板块-->
<!--用户权限说明-->
<!--采用3位编码制(第1位：科室；第2位：所操作页面/表单；第3位：操作权限)；如111：代表品质技术科 量检具点检表 管理员-->
<!--管理员：代码：1，可以做所有的操作-->
<template>
  <div style="margin: 0;padding: 0">
    <el-container>
      <!--页面表头设计-->
      <el-header style="height: 7vh">
        <el-link class="headMain" href="http://10.255.96.48:3404/">{{main.qualityManagementSystem}}</el-link>
          <span class="center-text">{{main.goodProductConditions}}</span>
        <el-popover
            placement="top-start"
            title="用户信息"
            width="200"
            trigger="hover">
          <div style="margin-top: 10px">Name：{{useName}}</div>
          <div style="margin-top: 10px">ID:{{useId}}</div>
          <div style="margin-top: 10px" @click="logOut"><el-link>退出</el-link></div>
          <div class="headMain" slot="reference">{{useName}}</div>
        </el-popover>
      </el-header>
      <el-container>
        <el-aside class="el-aside" width="200px" style="height: 90vh">
          <el-tree
              :data="projectList"
              props="defaultProps"
              accordion>
          </el-tree>
        </el-aside>
        <el-container>
          <!--主题设计-->
          <el-main class="el-main" style="height: 80vh;overflow: auto">
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <!--量检具基本信息-->
              <el-tab-pane :label="main.basicInformation" name="measuringToolsBasicInformation">
                <div style="text-align: right;margin-bottom: 5px;margin-top: -4px" >
                  <el-link size="small" @click="measuringToolsListEditShow(1,null)"><i class="el-icon-circle-plus-outline" v-if="usePower===111"></i></el-link>
                </div>
                <div>
                  <el-table
                      :data="measuringToolsListData"
                      style="width: 100%"
                      height="64vh"
                      border
                      highlight-current-row> <!-- 设置表头行高度 -->>

                    <!-- 序号 -->
                    <el-table-column
                        :label="pageVal.measuringToolChecklist.order"
                        width="60"
                        align="center"
                        v-slot:default="scope">
                      {{scope.$index+1}}
                    </el-table-column>

                    <!-- 编号 -->
                    <el-table-column
                        prop="number"
                        :label="pageVal.measuringToolsList.number"
                        width="125"
                        align="center">
                    </el-table-column>

                    <!-- 名称(中) -->
                    <el-table-column
                        prop="name"
                        :label="pageVal.measuringToolsList.name"
                        width="145"
                        align="center">
                    </el-table-column>

                    <!-- 名称(英) -->
                    <el-table-column
                        prop="name_english"
                        :label="pageVal.measuringToolsList.name_english"
                        width="155"
                        align="center">
                    </el-table-column>

                    <!-- 名称(英) -->
                    <el-table-column
                        prop="name_russian"
                        :label="pageVal.measuringToolsList.name_russian"
                        width="155"
                        align="center">
                    </el-table-column>

                    <!-- 规格型号 -->
                    <el-table-column
                        prop="specification"
                        :label="pageVal.measuringToolsList.specification"
                        width="180"
                        align="center">
                    </el-table-column>

                    <!-- 是否点检 -->
                    <el-table-column
                        prop="is_checked"
                        :label="pageVal.measuringToolsList.is_checked"
                        width="120"
                        align="center">
                    </el-table-column>

                    <!-- 点检频次 -->
                    <el-table-column
                        prop="inspection_frequency"
                        :label="pageVal.measuringToolsList.inspection_frequency"
                        width="120"
                        align="center">
                    </el-table-column>

                    <!-- 是否校准 -->
                    <el-table-column
                        prop="is_calibration"
                        :label="pageVal.measuringToolsList.is_calibration"
                        width="120"
                        align="center">
                    </el-table-column>

                    <!-- 校准周期 -->
                    <el-table-column
                        prop="calibration_cycle"
                        :label="pageVal.measuringToolsList.calibration_cycle"
                        width="120"
                        align="center">
                    </el-table-column>
                    <el-table-column
                    :label="main.edit"
                    align="center"
                    v-slot:default="scope"
                    v-if="usePower===111">
                      <el-link style="margin-right: 8px" @click="measuringToolsListEditShow(2,scope)">
                        <i class="el-icon-edit"></i>
                      </el-link>
                      <el-link @click="deleteDataShow('deleteMeasuringToolsListOneRow',scope)">
                        <i class="el-icon-delete"></i>
                      </el-link>
                    </el-table-column>
                  </el-table>
                </div>
              </el-tab-pane>

              <!--量检具点检管理-->
              <el-tab-pane :label="main.inspectionManagement" name="measuringToolsInspectionManagement">
                <div style="text-align: right">
                  <!--时间选择器-->
                  <el-date-picker
                      size="mini"
                      style="width: 125px; margin-right: 10px"
                      v-model="dateSelect"
                      type="date"
                      placeholder="选择日期"
                      value-format="yyyy-MM-dd"
                      format="yyyy-MM-dd">
                  </el-date-picker>

                  <!--班次选择器-->
                  <el-select
                      v-model="shiftSelect"
                      placeholder="选择班次"
                      size="mini"
                      style="width: 230px">
                    <el-option
                        v-for="item in shiftOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                    </el-option>
                  </el-select>
                </div>
                <div style="display: flex; width: 185vh; border: 1px solid #ccc;margin-top: 5px;">
                  <div style="flex: 1; border-right: 1px solid #ccc; padding: 8px;">
                    <el-table
                        :data="measuringToolChecklistData"
                        style="width: 100%"
                        height="58vh"
                        border
                        highlight-current-row> <!-- 设置表头行高度 -->>

                      <!-- 序号 -->
                      <el-table-column
                          :label="pageVal.measuringToolChecklist.order"
                          width="60"
                          align="center"
                          v-slot:default="scope">
                        {{scope.$index+1}}
                      </el-table-column>

                      <!-- 编号 -->
                      <el-table-column
                          prop="number"
                          :label="pageVal.measuringToolChecklist.number"
                          width="140"
                          align="center">
                      </el-table-column>

                      <!-- 名称(中) -->
                      <el-table-column
                          prop="name"
                          :label="pageVal.measuringToolChecklist.name"
                          width="160"
                          align="center"
                          v-slot:default="scope">
                        <span v-if="languageS==='chinese'">{{scope.row.name}}</span>
                        <span v-if="languageS==='english'">{{scope.row.name_english}}</span>
                        <span v-if="languageS==='russian'">{{scope.row.name_russian}}</span>
                      </el-table-column>

                      <!-- 是否合格 -->
                      <el-table-column
                          prop="is_qualified"
                          :label="pageVal.measuringToolChecklist.is_qualified"
                          width="100"
                          align="center">
                      </el-table-column>

                      <!-- 异常描述 -->
                      <el-table-column
                          prop="abnormal_description"
                          :label="pageVal.measuringToolChecklist.abnormal_description"
                          width="180"
                          align="center">
                      </el-table-column>

                      <el-table-column
                          :label="main.edit"
                          align="center"
                          v-slot:default="scope"
                          v-if="usePower===111">
                        <el-link style="margin-right: 8px" @click="measuringToolsListEditShow(2,scope)">
                          <i class="el-icon-edit"></i>
                        </el-link>
                        <el-link @click="deleteDataShow('deleteMeasuringToolsListOneRow',scope)">
                          <i class="el-icon-delete"></i>
                        </el-link>
                      </el-table-column>
                    </el-table>
                  </div>
                  <div style="width: 255px; padding: 8px;margin-right: 2px">
                    <el-table
                        :data="measuringToolCheckResult"
                        style="width: 100%"
                        height="58vh"
                        border
                        highlight-current-row> <!-- 设置表头行高度 -->>

                      <!-- 点检频次 -->
                      <el-table-column
                          prop="frequency"
                          :label="pageVal.measuringToolChecklist.frequency"
                          width="80"
                          align="center">
                      </el-table-column>

                      <!-- 应点检 -->
                      <el-table-column
                          prop="shouldCheck"
                          :label="pageVal.measuringToolChecklist.shouldCheck"
                          width="80"
                          align="center">
                      </el-table-column>

                      <!-- 实际点检 -->
                      <el-table-column
                          prop="actualCheck"
                          :label="pageVal.measuringToolChecklist.actualCheck"
                          width="80"
                          align="center">
                      </el-table-column>

                    </el-table>
                  </div>
                </div>
              </el-tab-pane>

              <!--量检具校准管理-->
              <el-tab-pane :label="main.calibrationManagement" name="measuringToolsCalibrationManagement"></el-tab-pane>


            </el-tabs>
          </el-main>
          <el-footer class="el-footer" style="height: 8vh">
            <el-button plain size="mini" @click="languageSelect('chinese')">中  文</el-button>
            <el-button plain size="mini" @click="languageSelect('russian')">Русский язык</el-button>
            <el-button plain size="mini" @click="languageSelect('english')">English</el-button>
          </el-footer>
        </el-container>
      </el-container>
    </el-container>

    <!--弹窗放置区-->
    <!--新增一条或编辑某一条计量器具基本信息-->
    <el-dialog
        :title="titleMessage"
        :visible.sync="measuringToolsListDialog"
        width="400px"
        :before-close="handleClose">
      <el-form :inline="true" ref="measuringToolsListForm" :model="measuringToolsListForm" label-width="100px" size="small">
        <el-form-item label="编号" required>
          <el-input v-model="measuringToolsListForm.number"></el-input>
        </el-form-item>
        <el-form-item label="名称(中)" required>
          <el-input v-model="measuringToolsListForm.name"></el-input>
        </el-form-item>
        <el-form-item label="名称(英)" required>
          <el-input v-model="measuringToolsListForm.name_english"></el-input>
        </el-form-item>
        <el-form-item label="名称(俄)" required>
          <el-input v-model="measuringToolsListForm.name_russian"></el-input>
        </el-form-item>
        <el-form-item label="规格型号" required>
          <el-input v-model="measuringToolsListForm.specification"></el-input>
        </el-form-item>
        <el-form-item label="是否点检" required>
          <el-select v-model="measuringToolsListForm.is_checked" style="width: 95%">
            <el-option label="YES" value="yes"></el-option>
            <el-option label="NO" value="no"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="点检频次" required>
          <el-select v-model="measuringToolsListForm.inspection_frequency" style="width: 95%">
            <el-option label="1shift" value="1shift"></el-option>
            <el-option label="1day" value="1day"></el-option>
            <el-option label="3days" value="3days"></el-option>
            <el-option label="1week" value="1week"></el-option>
            <el-option label="2weeks" value="2weeks"></el-option>
            <el-option label="1month" value="1month"></el-option>
            <el-option label="3months" value="3months"></el-option>
            <el-option label="6months" value="6months"></el-option>
            <el-option label="1year" value="1year"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否校准" required>
          <el-select v-model="measuringToolsListForm.is_calibration" style="width: 95%">
            <el-option label="YES" value="yes"></el-option>
            <el-option label="NO" value="no"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="校准周期" required>
          <el-select v-model="measuringToolsListForm.calibration_cycle" style="width: 95%">
            <el-option label="1day" value="1day"></el-option>
            <el-option label="3days" value="3days"></el-option>
            <el-option label="1week" value="1week"></el-option>
            <el-option label="2weeks" value="2weeks"></el-option>
            <el-option label="1month" value="1month"></el-option>
            <el-option label="3months" value="3months"></el-option>
            <el-option label="6months" value="6months"></el-option>
            <el-option label="1year" value="1year"></el-option>
            <el-option label="——" value="——"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="measuringToolsListDialog = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="measuringToolsListOk" size="mini">确 定</el-button>
      </span>
    </el-dialog>

    <!--删除某一条数据的弹窗-->
    <el-dialog
        :title="titleMessage"
        :visible.sync="deleteDataDialog"
        width="400px"
        :before-close="handleClose">
      <span>确定删除数据吗？</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="deleteDataDialog = false" size="mini">取 消</el-button>
        <el-button type="primary"  size="mini" @click="deleteDataOk">确 定</el-button>
      </span>
    </el-dialog>

    <!--抽屉放置区域-->
  </div>
</template>

<script>

import _ from "lodash";
import {getDaysInMonth, parseISO} from 'date-fns';

export default {
  name: "goodProductConditions",
  data() {
    return {
      activeName:'measuringToolsBasicInformation',
      //用户权限相关的变量
      useName:'',//用户名称
      useId:'',//用户编号
      usePower:'',//用户权限

      //用户登录后默认为中文
      languageS:'chinese',
      //切换语言，页面变量
      main:{
        qualityManagementSystem:'俄动力质量管理系统',
        goodProductConditions:'良品条件业务',

        edit:'编辑',

        basicInformation:'量检具基本信息',
        inspectionManagement: '量检具点检管理',
        calibrationManagement: '量检具校准管理'
      },
      pageVal:{
        measuringToolsList:{
          order:'序号',
          number:'编号',
          name:'名称(中)',
          name_english:'名称(英)',
          name_russian:'名称(俄)',
          specification:'规格型号',
          is_checked:'是否点检',
          inspection_frequency:'点检频次',
          is_calibration:'是否校准',
          calibration_cycle:'校准周期'
        },
        measuringToolChecklist:{
          order:'序号',
          number:'编号',
          name:'名称(中)',
          name_english:'名称(英)',
          name_russian:'名称(俄)',
          is_qualified:'是否合格',
          abnormal_description:'异常描述',
          frequency:'点检频次',
          shouldCheck:'应点检',
          actualCheck:'实际点检'
        },
      },

      //良品条件的导航
      projectList:[
        {
          label: '品质管理科',
          children: [
              {label: '量检具',},
          ]
        },
      ],

      //计量器具基本信息
      measuringToolsListData:[
        {
          //唯一标识，低代码的主键
          id:'',
          //创建时间
          create_time:'',
          //更新时间
          update_time:'',
          //创建人
          creator:'',
          //更新人
          sys_update_user:'',
          //逻辑删除
          sys_deleted:'',
          //自有系统的主键
          idUse:0,
          //创建时间
          establishTime:'',
          //修改时间
          updateTime:'',

          //编号
          number:'',
          //名称
          name:'',
          //名称(英)
          name_english:'',
          //名称(俄)
          name_russian:'',
          //规格型号
          specification:'',
          //是否点检
          is_checked:'',
          //点检频次
          inspection_frequency:'',
          //是否校准
          is_calibration:'',
          //校准周期
          calibration_cycle:'',
        }
      ],
      //计量器具基本信息表
      measuringToolsListForm:{
        //唯一标识，低代码的主键
        id:'',
        //创建时间
        create_time:'',
        //更新时间
        update_time:'',
        //创建人
        creator:'',
        //更新人
        sys_update_user:'',
        //逻辑删除
        sys_deleted:'',
        //自有系统的主键
        idUse:0,
        //创建时间
        establishTime:'',
        //修改时间
        updateTime:'',

        //编号
        number:'',
        //名称
        name:'',
        //名称(英)
        name_english:'',
        //名称(俄)
        name_russian:'',
        //规格型号
        specification:'',
        //是否点检
        is_checked:'',
        //点检频次
        inspection_frequency:'',
        //是否校准
        is_calibration:'',
        //校准周期
        calibration_cycle:'',
      },
      //记录用户要对表进行哪项操作，1.插入，2，编辑，3删除
      measuringToolsListDoe:0,
      //记录用户当前点击了哪一行
      measuringToolsListScope:null,

      //计量器具基本信息
      measuringToolChecklistData:[
        {
          //唯一标识，低代码的主键
          id:'',
          //创建时间
          create_time:'',
          //更新时间
          update_time:'',
          //创建人
          creator:'',
          //更新人
          sys_update_user:'',
          //逻辑删除
          sys_deleted:'',
          //自有系统的主键
          idUse:0,
          //创建时间
          establishTime:'',
          //修改时间
          updateTime:'',

          //编号
          number:'',
          //名称
          name:'',
          //名称(英)
          name_english:'',
          //名称(俄)
          name_russian:'',
          //规格型号
          specification:'',
          //是否合格
          is_qualified:'',
          //点检频次
          abnormal_description:'',
        }
      ],

      //弹出用到的变量
      titleMessage:'提示',
      //判断用户要删除哪个数据
      deleteDatDoe:'',

      //控制编辑计量器具基本信息的弹窗,默认关闭
      measuringToolsListDialog:false,
      //控制删除数据的弹窗,默认关闭
      deleteDataDialog:false,

      //班次选择选项
      shiftOptions: [
          {value: '早班/morning Shift/Ранняя смена', label: '早班/morning Shift/Ранняя смена'},
          {value: '中班/middle shift/Средний класс', label: '中班/middle shift/Средний класс'},
          {value: '夜班/night shift/Ночная работа', label: '夜班/night shift/Ночная работа'}
      ],
      //定义日期选择
      dateSelect:'',
      //定义班次选择
      shiftSelect:'',

      //定义点检频次、应点检、实际点检
      measuringToolCheckResult: [
        { frequency: '1shift', shouldCheck: '', actualCheck: '' },
        { frequency: '1day', shouldCheck: '', actualCheck: '' },
        { frequency: '3days', shouldCheck: '', actualCheck: '' },
        { frequency: '1week', shouldCheck: '', actualCheck: '' },
        { frequency: '2weeks', shouldCheck: '', actualCheck: '' },
        { frequency: '1month', shouldCheck: '', actualCheck: '' },
        { frequency: '3months', shouldCheck: '', actualCheck: '' },
        { frequency: '6months', shouldCheck: '', actualCheck: '' },
        { frequency: '1year', shouldCheck: '', actualCheck: '' }
      ]
    }
  },
  watch: {
    //监视shiftSelect变量
    // eslint-disable-next-line no-unused-vars
    shiftSelect(newVal,oldVal){
      //如果日期选择不为空时
      if (this.dateSelect!=='' && this.dateSelect!==null && this.dateSelect!==undefined){
        let timeTemp=[]
        //当班次选择早班时，转化为北京时间
        if (this.shiftSelect==='早班/morning Shift/Ранняя смена'){
          timeTemp=[this.dateSelect+' 13:20:00',this.dateSelect+' 22:20:00']
          console.log(timeTemp)
        }
        else if (this.shiftSelect==='中班/middle shift/Средний класс'){
          // 1. 将日期字符串转换为Date对象
          const date = new Date(this.dateSelect);

          // 2. 获取下一天的日期
          const nextDay = new Date(date);
          nextDay.setDate(date.getDate() + 1);

          // 3. 将下一天日期转换回字符串格式
          const nextDayStr = nextDay.toISOString().split('T')[0]
          timeTemp=[this.dateSelect+' 22:20:00',nextDayStr+' 07:20:00']
          console.log(timeTemp,'中班')
        }
        else if (this.shiftSelect==='夜班/night shift/Ночная работа'){
          // 1. 将日期字符串转换为Date对象
          const date = new Date(this.dateSelect);

          // 2. 获取下一天的日期
          const nextDay = new Date(date);
          nextDay.setDate(date.getDate() + 1);

          // 3. 将下一天日期转换回字符串格式
          const nextDayStr = nextDay.toISOString().split('T')[0]
          timeTemp=[nextDayStr+' 07:20:00',nextDayStr+' 13:20:00']
          console.log(timeTemp,'夜班')
        }
        if(timeTemp.length===2){
          this.$request.post('/queryMeasuringToolChecklistOneFieldScopeGoodProduct',{
            fieldName:'create_time',
            minVal:timeTemp[0],
            maxVal:timeTemp[1],
          }).then(result=>{
            if (result.code === 401) {
              this.$router.push('UserLogin')
              alert("您未登录，请登录")
            }else {
              this.measuringToolChecklistData=result.data
            }
          })
        }
      }
    },
    //监视dateSelect变量
    // eslint-disable-next-line no-unused-vars
    dateSelect(newVal,oldVal){
      let timeTemp=[]
      if (this.shiftSelect==='早班/morning Shift/Ранняя смена'){
        timeTemp=[this.dateSelect+' 13:20:00',this.dateSelect+' 22:20:00']
      }
      else if (this.shiftSelect==='中班/middle shift/Средний класс'){
        // 1. 将日期字符串转换为Date对象
        const date = new Date(this.dateSelect);

        // 2. 获取下一天的日期
        const nextDay = new Date(date);
        nextDay.setDate(date.getDate() + 1);

        // 3. 将下一天日期转换回字符串格式
        const nextDayStr = nextDay.toISOString().split('T')[0]
        timeTemp=[this.dateSelect+' 22:20:00',nextDayStr+' 07:20:00']
      }
      else if (this.shiftSelect==='夜班/night shift/Ночная работа'){
        // 1. 将日期字符串转换为Date对象
        const date = new Date(this.dateSelect);

        // 2. 获取下一天的日期
        const nextDay = new Date(date);
        nextDay.setDate(date.getDate() + 1);

        // 3. 将下一天日期转换回字符串格式
        const nextDayStr = nextDay.toISOString().split('T')[0]
        timeTemp=[nextDayStr+' 07:20:00',nextDayStr+' 13:20:00']
      }
      if(timeTemp.length===2){
        this.$request.post('/queryMeasuringToolChecklistOneFieldScopeGoodProduct',{
          fieldName:'create_time',
          minVal:timeTemp[0],
          maxVal:timeTemp[1],
        })
            .then(result=>{
          if (result.code === 401) {
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }else {
            this.measuringToolChecklistData=result.data
          }
        })
      }

      //循坏，输出各频次下对应的是否点检为“yes”的数量
      //在 for 循环中，i 从 0 开始递增，遍历 this.measuringToolCheckResult 数组
      for (let i = 0; i < this.measuringToolCheckResult.length; i++) {
        //筛选出应该点检的数量，temp(数组)即为应该点检的数量
        //[i]为数组索引，用于存储应点检数量，实际点检数量
        let temp=this.filterMeasuringToolListIsChecked('yes',this.measuringToolCheckResult[i].frequency)
        let temp1=[]
        //将应点检数量设置为筛选结果的长度
        this.measuringToolCheckResult[i].shouldCheck=temp.length
        //输出实际点检值
        //如果应点检为0，那么实际点检就为0
        if (this.measuringToolCheckResult[i].shouldCheck===0){
          this.measuringToolCheckResult[i].actualCheck=0
        }
        //如果应点检不为0，输出实际点检的数量
        else {

          //timeTemp 是一个时间范围数组，用于存储查询点检记录的时间区间（开始时间和结束时间）。
          //它的格式通常是：[开始时间, 结束时间]
          timeTemp=[]
          //如果班次选择及日期选择不为空，计算实际点检数
          if (this.shiftSelect!=='' && this.shiftSelect!==undefined && this.shiftSelect!==null){
            if (this.dateSelect!=='' && this.dateSelect!==undefined && this.dateSelect!==null){
              //如果点检频次为一个班次，则要判断所选班次为早、中、晚班
              if (this.measuringToolCheckResult[i].frequency==='1shift'){
                if (this.shiftSelect==='早班/morning Shift/Ранняя смена'){
                  timeTemp=[this.dateSelect+' 13:20:00',this.dateSelect+' 22:20:00']
                }
                else if (this.shiftSelect==='中班/middle shift/Средний класс'){
                  // 1. 将日期字符串转换为Date对象
                  const date = new Date(this.dateSelect);
                  // 2. 获取下一天的日期
                  const nextDay = new Date(date);
                  nextDay.setDate(date.getDate() + 1);
                  // 3. 将下一天日期转换回字符串格式
                  const nextDayStr = nextDay.toISOString().split('T')[0]
                  timeTemp=[this.dateSelect+' 22:20:00',nextDayStr+' 07:20:00']
                }
                else if (this.shiftSelect==='夜班/night shift/Ночная работа'){
                  // 1. 将日期字符串转换为Date对象
                  const date = new Date(this.dateSelect);
                  // 2. 获取下一天的日期
                  const nextDay = new Date(date);
                  nextDay.setDate(date.getDate() + 1);
                  // 3. 将下一天日期转换回字符串格式
                  const nextDayStr = nextDay.toISOString().split('T')[0]
                  timeTemp=[nextDayStr+' 07:20:00',nextDayStr+' 13:20:00']
                }
              }
              else if(this.measuringToolCheckResult[i].frequency==='1day'){
                timeTemp=this.subtractDays(this.dateSelect,1)
              }
              else if (this.measuringToolCheckResult[i].frequency==='3days'){
                timeTemp=this.subtractDays(this.dateSelect,3)
              }
              else if (this.measuringToolCheckResult[i].frequency==='1week'){
                timeTemp=this.subtractDays(this.dateSelect,7)
              }
              else if (this.measuringToolCheckResult[i].frequency==='2weeks'){
                timeTemp=this.subtractDays(this.dateSelect,14)
              }
              else if (this.measuringToolCheckResult[i].frequency==='1month'){
                //因月份涉及大小月，使用date-fns库获取当月天数并计算时间范围
                let date = parseISO(this.dateSelect);
                let dayNmb=getDaysInMonth(date)
                timeTemp=this.subtractDays(this.dateSelect,dayNmb)
              }
              //处理季度、半年和年度点检的情况，计算相应月份的天数并获取时间范围
              else if (this.measuringToolCheckResult[i].frequency==='3months'){
                let dayNumber=this.calculateDaysAfterSubtractingMonths(this.dateSelect,3)
                timeTemp=this.subtractDays(this.dateSelect,dayNumber)
              }
              else if (this.measuringToolCheckResult[i].frequency==='6months'){
                let dayNumber=this.calculateDaysAfterSubtractingMonths(this.dateSelect,6)
                timeTemp=this.subtractDays(this.dateSelect,dayNumber)
              }
              else if (this.measuringToolCheckResult[i].frequency==='1year'){
                let dayNumber=this.calculateDaysAfterSubtractingMonths(this.dateSelect,12)
                timeTemp=this.subtractDays(this.dateSelect,dayNumber)
              }
            }
          }
          //检查时间范围是否正确，若不正确，则提示错误
          if (timeTemp.length!==2){
            this.$message.error('应点检数量计算错误，请联系管理员')
          }
          //若时间范围正确
          else {
            //向后端发送请求查询该时间范围内的实际点检记录
            this.$request.post('/queryMeasuringToolChecklistOneFieldScopeGoodProduct',{
              fieldName:'create_time',
              minVal:timeTemp[0],
              maxVal:timeTemp[1],
            })
                .then(result=>{
                  if (result.code === 401) {
                    this.$router.push('UserLogin')
                    alert("您未登录，请登录")
                  }else {
                    //将实际点检数设置为查询结果的数据长度
                    temp1=result.data
                    this.measuringToolCheckResult[i].actualCheck=0
                    for (let j = 0; j < temp.length; j++) {
                      for (let k = 0; k <temp1.length ; k++) {
                        if (temp[j].number===temp1[k].number){
                          this.measuringToolCheckResult[i].actualCheck=this.measuringToolCheckResult[i].actualCheck+1
                          break
                        }
                      }
                    }
                  }
                })
          }
        }
      }
    },
  },
  methods: {
    //退出登录
    logOut(){
      localStorage.removeItem('u_token');
      localStorage.removeItem('userName')
      this.$router.push('UserLogin')
    },
    //查询用户信息的函数
    inquiry(){
      //输入用户编号，向后端查询信息
      const useId=localStorage.getItem('userName').replace(/"/g, '');
      this.$request.post('/useQueryPower',{
        queryFiledName:'goodProductCondition',
        userId:useId,
      }).then(result=>{
        if (result.code === 401) {
          this.$router.push('UserLogin')
          alert("您未登录，请登录")
        }else {
          this.useName=result.data.name
          this.usePower=result.data.goodProductCondition
          this.useId=useId
          console.log(this.useId,this.usePower,this.useName)
        }
      })
    },
    //选择语言
    languageSelect(language){
      this.languageS=language
      // console.log(language)
      if (language==='chinese'){
        //main
        this.main.qualityManagementSystem='俄动力质量管理系统'
        this.main.goodProductConditions='良品条件业务'

        this.main.edit='编辑'

        this.main.basicInformation='量检具基本信息'
        this.main.inspectionManagement='量检具点检管理'
        this.main.calibrationManagement='量检具校准管理'
        //pageVal
        this.pageVal.measuringToolsList.order='序号'
        this.pageVal.measuringToolsList.number='编号'
        this.pageVal.measuringToolsList.name='名称(中)'
        this.pageVal.measuringToolsList.name_english='名称(英)'
        this.pageVal.measuringToolsList.name_russian='名称(俄)'
        this.pageVal.measuringToolsList.specification='规格型号'
        this.pageVal.measuringToolsList.is_checked='是否点检'
        this.pageVal.measuringToolsList.inspection_frequency='点检频次'
        this.pageVal.measuringToolsList.is_calibration='是否校准'
        this.pageVal.measuringToolsList.calibration_cycle='校准周期'

        this.pageVal.measuringToolChecklist.order='序号'
        this.pageVal.measuringToolChecklist.number='编号'
        this.pageVal.measuringToolChecklist.name='名称(中)'
        this.pageVal.measuringToolChecklist.name_english='名称(英)'
        this.pageVal.measuringToolChecklist.name_russian='名称(俄)'
        this.pageVal.measuringToolChecklist.is_qualified='是否合格'
        this.pageVal.measuringToolChecklist.abnormal_description='异常描述'
        this.pageVal.measuringToolChecklist.frequency='点检频次'
        this.pageVal.measuringToolChecklist.shouldCheck='应点检'
        this.pageVal.measuringToolChecklist.actualCheck='实际点检'
        // this.pageVal={
        //   main:{},
        //   measuringToolsList:{
        //     number:'编号'
        //   }
        // }
      }
      else if (language==='english') {
        //main
        this.main.qualityManagementSystem='Quality Management System'
        this.main.goodProductConditions='Good Product Conditions'

        this.main.edit='Edit'

        this.main.basicInformation='Basic information of measuring tools'
        this.main.inspectionManagement='Inspection management of measuring tools'
        this.main.calibrationManagement='Calibration management of measuring tools'
        //pageVal
        this.pageVal.measuringToolsList.order='Order'
        this.pageVal.measuringToolsList.number='Number'
        this.pageVal.measuringToolsList.name='Name_Chinese'
        this.pageVal.measuringToolsList.name_english='Name_English'
        this.pageVal.measuringToolsList.name_russian='Name_Russian'
        this.pageVal.measuringToolsList.specification='Specification'
        this.pageVal.measuringToolsList.is_checked='Is_Checked'
        this.pageVal.measuringToolsList.inspection_frequency='Inspection Frequency'
        this.pageVal.measuringToolsList.is_calibration='Is Calibrated'
        this.pageVal.measuringToolsList.calibration_cycle='Calibration Cycle'

        this.pageVal.measuringToolChecklist.order='Order'
        this.pageVal.measuringToolChecklist.number='Number'
        this.pageVal.measuringToolChecklist.name='Name_Chinese'
        this.pageVal.measuringToolChecklist.name_english='Name_English'
        this.pageVal.measuringToolChecklist.name_russian='Name_Russian'
        this.pageVal.measuringToolChecklist.is_qualified='Is Qualified?'
        this.pageVal.measuringToolChecklist.abnormal_description='Abnormal Description'
        this.pageVal.measuringToolChecklist.frequency='Frequency'
        this.pageVal.measuringToolChecklist.shouldCheck='Should Check'
        this.pageVal.measuringToolChecklist.actualCheck='Actual Check'
        // this.pageVal = {
        //   main: {},
        //   measuringToolsList: {
        //     number: 'number'
        //   }
        // }
      }
      else if (language==='russian') {
        //main
        this.main.qualityManagementSystem='Система управления качеством'
        this.main.goodProductConditions='Хорошие условия продукции'

        this.main.edit='Правка'

        this.main.basicInformation='Основная информация измерительных инструментов'
        this.main.inspectionManagement='управление инспекцией измерительных инструментов'
        this.main.calibrationManagement='управление калибровкой измерительных инструментов'
        //pageVal
        this.pageVal.measuringToolsList.order='Заказ'
        this.pageVal.measuringToolsList.number='Номер'
        this.pageVal.measuringToolsList.name='Имя_Китайский'
        this.pageVal.measuringToolsList.name_english='Имя_Aнглийский'
        this.pageVal.measuringToolsList.name_russian='Имя_Русский'
        this.pageVal.measuringToolsList.specification='Спецификация'
        this.pageVal.measuringToolsList.is_checked='Да_Проверено'
        this.pageVal.measuringToolsList.inspection_frequency='Частота инспекции'
        this.pageVal.measuringToolsList.is_calibration='Да_Калибрирован'
        this.pageVal.measuringToolsList.calibration_cycle='Цикл калибровки'

        this.pageVal.measuringToolChecklist.order='Заказ'
        this.pageVal.measuringToolChecklist.number='Номер'
        this.pageVal.measuringToolChecklist.name='Имя_Китайский'
        this.pageVal.measuringToolChecklist.name_english='Имя_Aнглийский'
        this.pageVal.measuringToolChecklist.name_russian='Имя_Русский'
        this.pageVal.measuringToolChecklist.is_qualified='Квалифицирован?'
        this.pageVal.measuringToolChecklist.abnormal_description='Абнормальное описание'
        this.pageVal.measuringToolChecklist.frequency='Частота'
        this.pageVal.measuringToolChecklist.shouldCheck='Должно проверить'
        this.pageVal.measuringToolChecklist.actualCheck='Фактическая проверка'
        // this.pageVal = {
        //   main: {},
        //   measuringToolsList: {
        //     number: 'Номер'
        //   }
        // }
        console.log(this.pageVal)
      }
    },
    //在tab控件上单击的函数
    handleClick(tab, event) {
      console.log(tab, event);

      //筛选是否点检中“yes”的数据
      if (this.activeName==='measuringToolsInspectionManagement'){
        //循坏，输出各频次下对应的是否点检为“yes”的数量
        //在 for 循环中，i 从 0 开始递增，遍历 this.measuringToolCheckResult 数组
        for (let i = 0; i < this.measuringToolCheckResult.length; i++) {
          //筛选出应该点检的数量，temp(数组)即为应该点检的数量
          //[i]为数组索引，用于存储应点检数量，实际点检数量
          let temp=this.filterMeasuringToolListIsChecked('yes',this.measuringToolCheckResult[i].frequency)
          let temp1=[]
          //将应点检数量设置为筛选结果的长度
          this.measuringToolCheckResult[i].shouldCheck=temp.length
          //输出实际点检值
          //如果应点检为0，那么实际点检就为0
          if (this.measuringToolCheckResult[i].shouldCheck===0){
            this.measuringToolCheckResult[i].actualCheck=0
          }
          //如果应点检不为0，输出实际点检的数量
          else {
            //timeTemp 是一个时间范围数组，用于存储查询点检记录的时间区间（开始时间和结束时间）。
            //它的格式通常是：[开始时间, 结束时间]
            let timeTemp=[]
            //如果班次选择及日期选择不为空，计算实际点检数
            if (this.shiftSelect!=='' && this.shiftSelect!==undefined && this.shiftSelect!==null){
              if (this.dateSelect!=='' && this.dateSelect!==undefined && this.dateSelect!==null){
                //如果点检频次为一个班次，则要判断所选班次为早、中、晚班
                if (this.measuringToolCheckResult[i].frequency==='1shift'){
                  if (this.shiftSelect==='早班/morning Shift/Ранняя смена'){
                    timeTemp=[this.dateSelect+' 13:20:00',this.dateSelect+' 22:20:00']
                  }
                  else if (this.shiftSelect==='中班/middle shift/Средний класс'){
                    // 1. 将日期字符串转换为Date对象
                    const date = new Date(this.dateSelect);
                    // 2. 获取下一天的日期
                    const nextDay = new Date(date);
                    nextDay.setDate(date.getDate() + 1);
                    // 3. 将下一天日期转换回字符串格式
                    const nextDayStr = nextDay.toISOString().split('T')[0]
                    timeTemp=[this.dateSelect+' 22:20:00',nextDayStr+' 07:20:00']
                  }
                  else if (this.shiftSelect==='夜班/night shift/Ночная работа'){
                    // 1. 将日期字符串转换为Date对象
                    const date = new Date(this.dateSelect);
                    // 2. 获取下一天的日期
                    const nextDay = new Date(date);
                    nextDay.setDate(date.getDate() + 1);
                    // 3. 将下一天日期转换回字符串格式
                    const nextDayStr = nextDay.toISOString().split('T')[0]
                    timeTemp=[nextDayStr+' 07:20:00',nextDayStr+' 13:20:00']
                  }
                }
                else if(this.measuringToolCheckResult[i].frequency==='1day'){
                  timeTemp=this.subtractDays(this.dateSelect,1)
                }
                else if (this.measuringToolCheckResult[i].frequency==='3days'){
                  timeTemp=this.subtractDays(this.dateSelect,3)
                }
                else if (this.measuringToolCheckResult[i].frequency==='1week'){
                  timeTemp=this.subtractDays(this.dateSelect,7)
                }
                else if (this.measuringToolCheckResult[i].frequency==='2weeks'){
                  timeTemp=this.subtractDays(this.dateSelect,14)
                }
                else if (this.measuringToolCheckResult[i].frequency==='1month'){
                  //因月份涉及大小月，使用date-fns库获取当月天数并计算时间范围
                  let date = parseISO(this.dateSelect);
                  let dayNmb=getDaysInMonth(date)
                  timeTemp=this.subtractDays(this.dateSelect,dayNmb)
                  console.log(timeTemp)
                }
                //处理季度、半年和年度点检的情况，计算相应月份的天数并获取时间范围
                else if (this.measuringToolCheckResult[i].frequency==='3months'){
                  let dayNumber=this.calculateDaysAfterSubtractingMonths(this.dateSelect,3)
                  timeTemp=this.subtractDays(this.dateSelect,dayNumber)
                }
                else if (this.measuringToolCheckResult[i].frequency==='6months'){
                  let dayNumber=this.calculateDaysAfterSubtractingMonths(this.dateSelect,6)
                  timeTemp=this.subtractDays(this.dateSelect,dayNumber)
                }
                else if (this.measuringToolCheckResult[i].frequency==='1year'){
                  let dayNumber=this.calculateDaysAfterSubtractingMonths(this.dateSelect,12)
                  timeTemp=this.subtractDays(this.dateSelect,dayNumber)
                }
              }
            }
            //检查时间范围是否正确，若不正确，则提示错误
            if (timeTemp.length!==2){
              this.$message.error('应点检数量计算错误，请联系管理员')
            }
            //若时间范围正确
            else {
              //向后端发送请求查询该时间范围内的实际点检记录
              this.$request.post('/queryMeasuringToolChecklistOneFieldScopeGoodProduct',{
                fieldName:'create_time',
                minVal:timeTemp[0],
                maxVal:timeTemp[1],
              })
                  .then(result=>{
                    if (result.code === 401) {
                      this.$router.push('UserLogin')
                      alert("您未登录，请登录")
                    }else {
                      //将实际点检数设置为查询结果的数据长度
                      temp1=result.data
                      this.measuringToolCheckResult[i].actualCheck=0
                      for (let j = 0; j < temp.length; j++) {
                        for (let k = 0; k <temp1.length ; k++) {
                          console.log('数据核对',temp[j].number,temp1[k].number)
                          if (temp[j].number===temp1[k].number){
                            console.log(temp[j].number,temp1[k].number)
                            this.measuringToolCheckResult[i].actualCheck=this.measuringToolCheckResult[i].actualCheck+1
                            break
                          }
                        }
                      }
                    }
                  })
            }
            console.log(timeTemp)
          }
        }
      }
    },
    //通用：误关闭弹窗的确认函数
    /* eslint-disable-line no-unused-vars */
    handleClose(done) {
      this.$confirm('确认关闭？')

          .then(/* eslint-disable-line no-unused-vars */ _ => {
            done();
          })
          .catch(/* eslint-disable-line no-unused-vars */ _ => {
          });
    },
    //显示编辑计量器具基本信息的弹窗，doe 1：添加，2：编辑；3：删除；
    measuringToolsListEditShow(doe,scope){
      this.measuringToolsListDoe=doe
      this.measuringToolsListScope=scope
      console.log(scope)
      //要对计量工具基础表进行插入
      //对doe进行赋值，当等于1时，提示表头信息
      if (doe===1){
        this.titleMessage='您正在插入一条计量器具基本信息'
        //对表单变量赋值，给一个空的
        this.measuringToolsListForm={
          //唯一标识，低代码的主键
          id:'',
          //创建时间
          create_time:'',
          //更新时间
          update_time:'',
          //创建人
          creator:'',
          //更新人
          sys_update_user:this.useId+'/'+this.useName,
          //逻辑删除
          sys_deleted:1,
          //自有系统的主键
          idUse:0,
          //创建时间
          establishTime:'',
          //修改时间
          updateTime:'',

          //编号
          number:'',
          //名称(中)
          name:'',
          //名称(英)
          name_english:'',
          //名称(俄)
          name_russian:'',
          //规格型号
          specification:'',
          //是否点检
          is_checked:'',
          //点检频次
          inspection_frequency:'',
          //是否校准
          is_calibration:'',
          //校准周期
          calibration_cycle:'',
        }
        //控制弹窗打开
        this.measuringToolsListDialog=true
      }

      //对doe进行赋值，当等于2时，提示表头信息
      else if (doe===2){
        this.titleMessage='您正在修改一条计量器具基本信息'
        //给表单赋值
        this.measuringToolsListForm=_.cloneDeep(scope.row)
        //控制弹窗打开
        this.measuringToolsListDialog=true
      }
    },
    //点击编辑计量器具基本信息弹窗中的确定
    measuringToolsListOk(){
      //数据校验：当用户有字段未输入内容时，提示未输入
      if(this.measuringToolsListForm.number==='' || this.measuringToolsListForm.number===null || this.measuringToolsListForm.number===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('您未输入"编号"，请输入')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the "number"')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите "номер"')
        }
        return
      }
      if(this.measuringToolsListForm.name==='' || this.measuringToolsListForm.name===null || this.measuringToolsListForm.name===undefined){
        if(this.languageS==='chinese'){
          this.$message.error('您未输入"名称(中)"，请输入')
        }
        else if(this.languageS==='english'){
          this.$message.error('Please enter the "name"')
        }
        else if(this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите "имя"')
        }
        return
      }
      if(this.measuringToolsListForm.name_english==='' || this.measuringToolsListForm.name_english===null || this.measuringToolsListForm.name_english===undefined){
        if(this.languageS==='chinese'){
          this.$message.error('您未输入"名称(英)"，请输入')
        }
        else if(this.languageS==='english'){
          this.$message.error('Please enter the "English name"')
        }
        else if(this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите "Английское имя"')
        }
        return
      }
      if(this.measuringToolsListForm.name_russian==='' || this.measuringToolsListForm.name_russian===null || this.measuringToolsListForm.name_russian===undefined){
        if(this.languageS==='chinese'){
          this.$message.error('您未输入"名称(俄)"，请输入')
        }
        else if(this.languageS==='english'){
          this.$message.error('Please enter the "Russian name"')
        }
        else if(this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите "русское имя"')
        }
        return
      }
      if(this.measuringToolsListForm.specification==='' || this.measuringToolsListForm.specification===null || this.measuringToolsListForm.specification===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('您未输入"规格型号"，请输入')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the "specification"')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите "спецификацию"')
        }
        return
      }
      if(this.measuringToolsListForm.is_checked==='' || this.measuringToolsListForm.is_checked===null || this.measuringToolsListForm.is_checked===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('您未选择"是否点检"，请选择')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please select the "Is_Checked"')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, выберите "Квалифицированный"')
        }
        return
      }
      if(this.measuringToolsListForm.inspection_frequency==='' || this.measuringToolsListForm.inspection_frequency===null || this.measuringToolsListForm.inspection_frequency===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('您未选择"点检频次"，请选择')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please select the "Inspection frequency"')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, выберите "Частота проверки"')
        }
        return
      }
      if(this.measuringToolsListForm.is_calibration==='' || this.measuringToolsListForm.is_calibration===null || this.measuringToolsListForm.is_calibration===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('您未选择"是否校准"，请选择')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please select the "Calibrate"')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, выберите "Калибрировать"')
        }
        return
      }
      if(this.measuringToolsListForm.calibration_cycle==='' || this.measuringToolsListForm.calibration_cycle===null || this.measuringToolsListForm.calibration_cycle===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('您未选择"校准周期"，请选择')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please select the "Calibration cycle"')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, выберите "Цикл калибровки"')
        }
        return
      }

      //当插入一行时
      if (this.measuringToolsListDoe===1){
        //向后端发送请求插入数据（①第一个参数是发送到哪个网址；②发送哪个数据）；result是指接收哪些数据
        this.$request.post('/insertMeasuringToolsListGoodProduct',this.measuringToolsListForm).then(result=>{
          //如果未接收到数据，执行用户登录界面
          if (result.code===401){
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }
          //如果成功接收到数据，在控制台打印数据并提示插入成功
          else{
            this.$message.success('插入成功')
            //修改大表数据
            this.queryMeasuringToolsListAll()
            //关闭窗口
            this.measuringToolsListDialog=false
          }
        })
      }
      //当编辑某一行时
      else if (this.measuringToolsListDoe===2){
        this.$request.post('/editMeasuringToolsListGoodProduct',this.measuringToolsListForm).then(result=>{
          //如果未接收到数据，执行用户登录界面
          if (result.code===401){
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }
          //如果成功接收到数据，在控制台打印数据并提示编辑成功
          else{
            this.$message.success('编辑成功')
            //修改大表数据
            this.measuringToolsListData.splice(this.measuringToolsListScope.$index,1,this.measuringToolsListForm)
            //关闭窗口
            this.measuringToolsListDialog=false
          }
        })
      }
    },

    //通用：点击删除按钮时的弹窗
    deleteDataShow(doe,scope){
      console.log(doe)
      this.deleteDatDoe=doe
      if (doe==='deleteMeasuringToolsListOneRow'){
        this.measuringToolsListScope=scope
        this.measuringToolsListForm=_.cloneDeep(scope.row)
        this.titleMessage='删除本行数据'
        this.deleteDataDialog=true
      }
    },
    //通用：删除某一行数据
    deleteDataOk(){
      if (this.deleteDatDoe==='deleteMeasuringToolsListOneRow'){
        //设置删除位的值为0
        this.measuringToolsListForm.sys_deleted=0
        this.$request.post('/editMeasuringToolsListGoodProduct',this.measuringToolsListForm).then(result=>{
          //如果未接收到数据，执行用户登录界面
          if (result.code===401){
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }
          //如果成功接收到数据，在控制台打印数据并提示编辑成功
          else{
            this.$message.success('编辑成功')
            //修改大表数据
            this.measuringToolsListData.splice(this.measuringToolsListScope.$index,1)
            //关闭窗口
            this.deleteDataDialog=false
          }
        })
      }
    },
    //辅助函数：查询计量器具基础信息表的所有信息
    queryMeasuringToolsListAll(){
      this.$request.post('/queryMeasuringToolsListAllGoodProduct').then(result=>{
        if(result.code===401){
          this.$router.push('UserLogin')
          alert("您未登录，请登录")
        }
        else{
          //将数据输出到页面表格中
          this.measuringToolsListData=result.data
        }
      })
    },

    //筛选是否点检中yes的数据,并筛选点检周期
    filterMeasuringToolListIsChecked(isCheckedValue,inspectionFrequencyValue){
      const filteredData = this.measuringToolsListData.filter(tool =>
          tool.is_checked === isCheckedValue &&
          tool.inspection_frequency === inspectionFrequencyValue
      );
      return filteredData
    },
    //计算点检频次为1个月的实际点检情况
    subtractDays(dateString, daysToSubtract) {
      // 1. 将日期字符串转换为 Date 对象
      const date = new Date(dateString);

      // 2. 检查日期是否有效
      if (isNaN(date.getTime())) {
        throw new Error("Invalid date string");
      }

      // 3. 减去指定天数（毫秒计算）
      date.setDate(date.getDate() - daysToSubtract);

      // 4. 格式化为 YYYY-MM-DD 字符串
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份补零
      const day = String(date.getDate()).padStart(2, '0'); // 日期补零

      return [`${year}-${month}-${day} ${'13:20:00'}`,`${dateString} ${'13:20:00'}`];
    },
    //计算点检频次为3个月的实际点检情况
    calculateDaysAfterSubtractingMonths(startDateStr, monthsToSubtract) {
      // 将输入的字符串转换为日期对象
      const startDate = new Date(startDateStr);
      if (isNaN(startDate.getTime())) {
        throw new Error('无效的日期格式，请使用"YYYY-MM-DD"格式');
      }

      // 创建开始日期的副本以避免修改原始日期
      const endDate = new Date(startDate);

      // 减去指定的月数
      endDate.setMonth(endDate.getMonth() - monthsToSubtract);

      // 处理跨年情况（setMonth会自动处理）

      // 计算两个日期之间的毫秒差
      const timeDiff = startDate - endDate;

      // 将毫秒转换为天数
      const daysDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24));

      return daysDiff;
    }

  },
  mounted() {
    this.inquiry()
    //组件加载后立即获取并显示列表数据
    this.queryMeasuringToolsListAll()
    this.measuringToolChecklistData=[]
    //默认获取当天早班的点检数据
    this.shiftSelect='早班/morning Shift/Ранняя смена'
    const today = new Date();
    this.dateSelect = today.toISOString().slice(0, 10);
    //发版时候删掉
    // this.dateSelect='2025-05-29'
    // this.shiftSelect='中班/middle shift/Средний класс'

  }
}
</script>

<style scoped>
/* 主体左侧的工作步骤栏用到的数据包围的div的样式*/

.el-footer {
  background-color: #ffffff;
  color: #333;
  text-align: center;
  border-width: 3px; /* 设置边框宽度为3像素 */
  border-color: blue; /* 设置边框颜色为蓝色 */
  border-style: solid; /* 设置边框样式为实线 */
  padding: 10px; /* 添加内边距 */
  border-left-color: white;
  border-top: white;
}

.el-aside {
  background-color: #ffffff;
  color: #333;
  text-align: center;
  border-width: 3px; /* 设置边框宽度为3像素 */
  border-color: blue; /* 设置边框颜色为蓝色 */
  border-style: solid; /* 设置边框样式为实线 */
  padding: 10px; /* 添加内边距 */
  height: 89vh;
}

.el-main {
  color: #333;
  text-align: center;
  border-width: 3px; /* 设置边框宽度为3像素 */
  border-color: blue; /* 设置边框颜色为蓝色 */
  border-left-color: white;
  border-style: solid; /* 设置边框样式为实线 */
  padding: 10px; /* 添加内边距 */
  overflow: auto;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.headMain{
  color: #ffffff; /* 设置字体颜色为红色 */
  font-size: 18px;
}
.center-text {
  /* 使用 margin-left 和 margin-right auto 来实现居中效果 */
  margin-left: auto;
  margin-right: auto;
  /* 注意：如果 header 内只有这两个元素，你可能不需要 margin-right: auto */
}
.el-container {
  overflow: auto; /* 自动显示滚动条当内容溢出时 */
  /* 或者 */
  overflow-x: auto; /* 仅水平滚动 */
  overflow-y: auto; /* 仅垂直滚动 */
}
/*自定义样式*/
</style>